import { defineStore } from 'pinia'
import { ref } from 'vue'
const initUserInfo = {
  departmentId: 0,
  departmentName: '',
  doctorId: 0,
  imagePic: '',
  inauguralHospital: '',
  jiGuangPwd: '',
  jobTitle: '',
  name: '',
  reviewStatus: 0,
  sessionId: '',
  userName: '',
  whetherHaveImagePic: 0
}

export const useUserHooks = defineStore(
  'user',
  () => {
    const isLogin = ref(false)
    const userInfo = ref(initUserInfo)

    const loginSuccess = (payload) => {
      userInfo.value = payload
      isLogin.value = true
    }

    const quitLogin = () => {
      userInfo.value = initUserInfo
      isLogin.value = false
    }

    return { isLogin, userInfo, loginSuccess, quitLogin }
  },
  {
    persist: true
  }
)
